package www.openteam.com.presenter.qualityCntrl;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.IQCCust00;
import www.openteam.com.bean.IQCMsg00;
import www.openteam.com.bean.IQCSamplePlan;
import www.openteam.com.contract.qualityCntrl.IQCContract;
import www.openteam.com.model.qualityCntrl.IQCModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.qualityCntrl.IQCFragment;

/**
 * Created by Administrator on 2018/1/31 0031.
 */

public class IQCPresenter extends BasePresenter<IQCFragment>
        implements IQCContract.IQC00Presenter {
    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new IQCModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> map = new HashMap<>();
        map.put("IQCPresenter",models[0]);
        return map;
    }

    @Override
    public void findSamplePalan() {
        ((IQCModel )getiModelMap().get("IQCPresenter")).findSamplePlan(new IQCModel.SamplePlanListener() {
            @Override
            public void success(IQCSamplePlan iqcSamplePlan) {
                getIView().findSamplePalan(iqcSamplePlan);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findCust00() {
        ((IQCModel)getiModelMap().get("IQCPresenter")).findCust00(new IQCModel.Cust00Listener() {
            @Override
            public void success(IQCCust00 iqcCust00) {
                getIView().findCust00(iqcCust00);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findMsg00(String code) {
        ((IQCModel)getiModelMap().get("IQCPresenter")).findMsg00(code, new IQCModel.Msg00Listener() {
            @Override
            public void success(IQCMsg00 iqcMsg00) {
                getIView().findMsg00(iqcMsg00);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }
}
